<template>
  <div class="container">
    <el-dialog
      title="预览文章"
      :visible.sync="dialogVisible"
      width="55%"
      :before-close="handleClose"
    >
      <div class="box">
        <h3>{{ form.title }}</h3>
        <span>{{ getItem }}</span>
        <span>{{ form.title }}</span>
        <span class="el-icon-view"></span>
        <span>{{ form.visits }}</span>
        <div class="butt" v-html="form.articleBody"></div>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  props: {
    text: {
      type: String
    }
  },
  data () {
    return {
      labelPosition: 'right',
      form: {},
      dialogVisible: false
    }
  },
  methods: {
    // TODO关闭弹窗
    handleClose () {
      this.dialogVisible = false
      // this.$refs.butt.innerHTML
    }
  },

  computed: {
    getItem () {
      const date = new Date(this.form.createTime)

      const y = date.getFullYear()
      let m = date.getMonth() + 1
      let d = date.getDate()
      let h = date.getHours()
      let min = date.getMinutes()
      let sec = date.getSeconds()

      m = m < 10 ? '0' + m : m
      d = d < 10 ? '0' + d : d
      h = h < 10 ? '0' + h : h
      min = min < 10 ? '0' + min : min
      sec = sec < 10 ? '0' + sec : sec

      return `${y}-${m}-${d} ${h}:${min}:${sec}`
    }
  }
}
</script>

<style scoped lang="less">
.butt {
  height: 70px;
  line-height: 70px;
  padding-left: 10px;
  margin-top: 5px;
  border-top: 1px dashed #ccc;
  background-color: #f5f5f5;
}
span {
  margin-right: 10px;
}
.roles {
  height: 300px;
  .role {
    height: 200px;
  }
}
</style>
